package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AvatarFrames;
import com.ruoyi.system.service.IAvatarFramesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 头像框表Controller
 * 
 * @author ruoyi
 * @date 2024-07-25
 */
@RestController
@RequestMapping("/system/frames")
public class AvatarFramesController extends BaseController
{
    @Autowired
    private IAvatarFramesService avatarFramesService;

    /**
     * 查询头像框表列表
     */
    @PreAuthorize("@ss.hasPermi('system:frames:list')")
    @GetMapping("/list")
    public TableDataInfo list(AvatarFrames avatarFrames)
    {
        startPage();
        List<AvatarFrames> list = avatarFramesService.selectAvatarFramesList(avatarFrames);
        return getDataTable(list);
    }

    /**
     * 导出头像框表列表
     */
    @PreAuthorize("@ss.hasPermi('system:frames:export')")
    @Log(title = "头像框表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AvatarFrames avatarFrames)
    {
        List<AvatarFrames> list = avatarFramesService.selectAvatarFramesList(avatarFrames);
        ExcelUtil<AvatarFrames> util = new ExcelUtil<AvatarFrames>(AvatarFrames.class);
        util.exportExcel(response, list, "头像框表数据");
    }

    /**
     * 获取头像框表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:frames:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(avatarFramesService.selectAvatarFramesById(id));
    }

    /**
     * 新增头像框表
     */
    @PreAuthorize("@ss.hasPermi('system:frames:add')")
    @Log(title = "头像框表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AvatarFrames avatarFrames)
    {
        return toAjax(avatarFramesService.insertAvatarFrames(avatarFrames));
    }

    /**
     * 修改头像框表
     */
    @PreAuthorize("@ss.hasPermi('system:frames:edit')")
    @Log(title = "头像框表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AvatarFrames avatarFrames)
    {
        return toAjax(avatarFramesService.updateAvatarFrames(avatarFrames));
    }

    /**
     * 删除头像框表
     */
    @PreAuthorize("@ss.hasPermi('system:frames:remove')")
    @Log(title = "头像框表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(avatarFramesService.deleteAvatarFramesByIds(ids));
    }
}
